#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QMap>

#include "ChannelSelect.h"
#include "SetWidget.h"
#include "PointManager.h"

class QCustomPlot;
class QCPItemLine;
class QCPItemStraightLine;
class QCPItemTracer;
class CurveTableView;
class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void SlotImportActionTriggered();
    void SlotChannelSelectActionTriggered();
    void SlotSetActionTriggered();
    void SlotChannelSelectShowPoints(const QStringList &ids);
    void SlotSetWidgetConfirmButtonClicked(qint64 xRangeMin, qint64 xRangeMax, double yRangeMin, double yRangeMax);
    void SlotButtonGroupIdChecked(int id);
    void SlotPlotMousePressed(QMouseEvent *event);

private:
    void Init();
    void InitChannelSelectWidget();
    void InitSetWidget();
    void ReadCSVFile(const QString &fileName);
    void UpdateCurve(bool isRescale = true);
    QCustomPlot *CreatePlot();

private:
    QCustomPlot *curvePlot{ nullptr };

    ChannelSelectWidget *channelSelect{ nullptr };
    SetWidget *setWidget{ nullptr };

    QCPItemStraightLine *leftLine{ nullptr };  //参考线
    QCPItemStraightLine *rightLine{ nullptr };  //参考线

    QDockWidget *tableDock{ nullptr };
    bool isImported{ false };
    CurveTableView *curveTableView{ nullptr };

    PointManager *pointManager{ nullptr };
};
#endif // MAINWINDOW_H
